#define _CRT_SECURE_NO_WARNINGS  1
#pragma warning(disable:6031)

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef int SLDataType;
typedef struct SeqList {
	SLDataType* arr;
	int capacity;
	int size;
}SL;

//typedef struct SeqList Sl;

void SLInit(SL* ps);
void SLDestory(SL* ps);
void SLInit(SL* ps) {
	ps->arr = NULL;
	ps->size = ps->capacity = 0;
}

typedef int SLDataType;
typedef struct SeqList {
	SLDataType* arr;
	int capacity;
	int size;
}SL;

void SLInit(SL* ps);
void SLDestory(SL* ps);

void SLPushBack(SL* ps, SLDataType x);
void SLPushFront(SL* ps, SLDataType x);

void SLinit(SL* ps) {
	ps->arr = NULL;
	ps->size = ps->capacity = 0;
}

void SLDestory(SL* ps) {
	assert(ps);
	if (ps->arr) {
		free(ps->arr);
	}
	ps->arr = NULL;
	ps->size = pa->capacity = 0;
}

//void SLPushBack(SL* ps, SLDataType x) {
//	assert(ps);
//	int newcapacity = (SLDataType*)realloc(ps->arr, newcapacity * sizeof(SLDataType));
//	if (ps->size == ps->capacity) {
//		SLDataType* tmp=(SLDataType*)
//	}
//}

void SLPushBack(SL* ps, SLDataType x) {
	assert(ps);
	int newcapacity = ps->capacity == 0 ? 4 : 2 * ps->capacity;
	if (ps->size == ps->capacity) {
		SLDataType* tmp = (SLDataType*)realloc(ps->arr, SLDataType * sizeof(SLDataType));
		if (tmp == NULL) {
			perror("realloc fail");
			exit(1);
		}
		ps->arr = tmp;
		ps->capacity = newcapacity;
	}
	ps->arr[ps->size++] = x;
	//ps->arr[ps->size]=x;
	//ps->size++;
}

void SLPushFront(SL* ps, SLDataType x);

void SLPrint(SL* ps) {
	assert(ps);
	for (int i = 0; i < ps->size; ++i) {
		print("%d", ps->arr[i]);
	}
	print("\n");
}

typedef int SLDataType;
typedef struct SeqList {
	SLDataType* arr;
	int capacity;
	int size;
};

void SLInit(SL* ps);
void SLDestory(SL* ps);
void SLPushBack(SL* ps, SLDataType x);
void SLPushFront(SL* ps, SLDataType);

